package com.my.jli.util;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName CookieUtil
 * @Description cookie工具类
 * @Author MaYu
 * @Date 2022/3/28 11:47
 * @Version 1.0
 **/
public class CookieUtil {
    public static void setCookie(HttpServletResponse response, String key, String value, int expiry){
        Cookie cookie = new Cookie(key, value);
        //设置最大存活时间
        cookie.setMaxAge(expiry);
        //cookie.setSecure(true);
        //cookie.setHttpOnly(true);
        response.addCookie(cookie);
    }
}
